package com.xianggu.schedule;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author chengjy
 * @date 2025/3/15
 */
public class ScheduleDemo {

    private static ScheduleService scheduleService = new ScheduleService();
    public static void main(String[] args) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
        scheduleService.schedule(new Runnable() {
            @Override
            public void run() {
                System.out.println("\r\n定时任务一执行："+ format.format(new Date()));
            }
        } , 5000    );
        System.out.println("任务一启动……");
        scheduleService.schedule(new Runnable() {
            @Override
            public void run() {
                System.out.println("\r\n定时任务二执行："+ format.format(new Date()));
            }
        } , 2000   );
        System.out.println("任务二启动……");
        scheduleService.schedule(new Runnable() {
            @Override
            public void run() {
                System.out.println("\r\n定时任务三执行："+ format.format(new Date()));
            }
        } , 1000   );
        System.out.println("任务三启动……");
    }
}
